import { createModule } from './dist/libredwg-web.js'

// load libredwg webassembly module
export const libredwg = await createModule()

export const Dwg_Object_Type = Object.freeze({
  DWG_TYPE_UNUSED: 0x00,
  DWG_TYPE_TEXT: 0x01,
  DWG_TYPE_ATTRIB: 0x02,
  DWG_TYPE_ATTDEF: 0x03,
  DWG_TYPE_BLOCK: 0x04,
  DWG_TYPE_ENDBLK: 0x05,
  DWG_TYPE_SEQEND: 0x06,
  DWG_TYPE_INSERT: 0x07,
  DWG_TYPE_MINSERT: 0x08,
  // DWG_TYPE_TRACE_old: 0x09, /* old TRACE r10-r11 only */
  DWG_TYPE_VERTEX_2D: 0x0a,
  DWG_TYPE_VERTEX_3D: 0x0b,
  DWG_TYPE_VERTEX_MESH: 0x0c,
  DWG_TYPE_VERTEX_PFACE: 0x0d,
  DWG_TYPE_VERTEX_PFACE_FACE: 0x0e,
  DWG_TYPE_POLYLINE_2D: 0x0f,
  DWG_TYPE_POLYLINE_3D: 0x10,
  DWG_TYPE_ARC: 0x11,
  DWG_TYPE_CIRCLE: 0x12,
  DWG_TYPE_LINE: 0x13,
  DWG_TYPE_DIMENSION_ORDINATE: 0x14,
  DWG_TYPE_DIMENSION_LINEAR: 0x15,
  DWG_TYPE_DIMENSION_ALIGNED: 0x16,
  DWG_TYPE_DIMENSION_ANG3PT: 0x17,
  DWG_TYPE_DIMENSION_ANG2LN: 0x18,
  DWG_TYPE_DIMENSION_RADIUS: 0x19,
  DWG_TYPE_DIMENSION_DIAMETER: 0x1a,
  DWG_TYPE_POINT: 0x1b,
  DWG_TYPE__3DFACE: 0x1c,
  DWG_TYPE_POLYLINE_PFACE: 0x1d,
  DWG_TYPE_POLYLINE_MESH: 0x1e,
  DWG_TYPE_SOLID: 0x1f,
  DWG_TYPE_TRACE: 0x20,
  DWG_TYPE_SHAPE: 0x21,
  DWG_TYPE_VIEWPORT: 0x22,
  DWG_TYPE_ELLIPSE: 0x23,
  DWG_TYPE_SPLINE: 0x24,
  DWG_TYPE_REGION: 0x25,
  DWG_TYPE__3DSOLID: 0x26,
  DWG_TYPE_BODY: 0x27,
  DWG_TYPE_RAY: 0x28,
  DWG_TYPE_XLINE: 0x29,
  DWG_TYPE_DICTIONARY: 0x2a,
  DWG_TYPE_OLEFRAME: 0x2b,
  DWG_TYPE_MTEXT: 0x2c,
  DWG_TYPE_LEADER: 0x2d,
  DWG_TYPE_TOLERANCE: 0x2e,
  DWG_TYPE_MLINE: 0x2f,
  DWG_TYPE_BLOCK_CONTROL: 0x30,
  DWG_TYPE_BLOCK_HEADER: 0x31,
  DWG_TYPE_LAYER_CONTROL: 0x32,
  DWG_TYPE_LAYER: 0x33,
  DWG_TYPE_STYLE_CONTROL: 0x34 /* 52 SHAPEFILE_CONTROL */,
  DWG_TYPE_STYLE: 0x35,
  /* DWG_TYPE_<UNKNOWN>: 0x36, */
  /* DWG_TYPE_<UNKNOWN>: 0x37, */
  DWG_TYPE_LTYPE_CONTROL: 0x38,
  DWG_TYPE_LTYPE: 0x39,
  /* DWG_TYPE_<UNKNOWN>: 0x3a, */
  /* DWG_TYPE_<UNKNOWN>: 0x3b, */
  DWG_TYPE_VIEW_CONTROL: 0x3c,
  DWG_TYPE_VIEW: 0x3d,
  DWG_TYPE_UCS_CONTROL: 0x3e,
  DWG_TYPE_UCS: 0x3f,
  DWG_TYPE_VPORT_CONTROL: 0x40,
  DWG_TYPE_VPORT: 0x41,
  DWG_TYPE_APPID_CONTROL: 0x42,
  DWG_TYPE_APPID: 0x43,
  DWG_TYPE_DIMSTYLE_CONTROL: 0x44,
  DWG_TYPE_DIMSTYLE: 0x45,
  DWG_TYPE_VX_CONTROL: 0x46,
  DWG_TYPE_VX_TABLE_RECORD: 0x47,
  DWG_TYPE_GROUP: 0x48,
  DWG_TYPE_MLINESTYLE: 0x49,
  DWG_TYPE_OLE2FRAME: 0x4a,
  DWG_TYPE_DUMMY: 0x4b,
  DWG_TYPE_LONG_TRANSACTION: 0x4c,
  DWG_TYPE_LWPOLYLINE: 0x4d /* ?? */,
  DWG_TYPE_HATCH: 0x4e,
  DWG_TYPE_XRECORD: 0x4f,
  DWG_TYPE_PLACEHOLDER: 0x50,
  DWG_TYPE_VBA_PROJECT: 0x51,
  DWG_TYPE_LAYOUT: 0x52,

  DWG_TYPE_PROXY_ENTITY: 0x1f2 /* 498 */,
  DWG_TYPE_PROXY_OBJECT: 0x1f3 /* 499 */,

  /* non-fixed types > 500. not stored as type, but as fixedtype */

  DWG_TYPE_ACDSRECORD: 500,
  DWG_TYPE_ACDSSCHEMA: 501,
  DWG_TYPE_ACMECOMMANDHISTORY: 502,
  DWG_TYPE_ACMESCOPE: 503,
  DWG_TYPE_ACMESTATEMGR: 504,
  DWG_TYPE_ACSH_BOOLEAN_CLASS: 505,
  DWG_TYPE_ACSH_BOX_CLASS: 506,
  DWG_TYPE_ACSH_BREP_CLASS: 507,
  DWG_TYPE_ACSH_CHAMFER_CLASS: 508,
  DWG_TYPE_ACSH_CONE_CLASS: 509,
  DWG_TYPE_ACSH_CYLINDER_CLASS: 510,
  DWG_TYPE_ACSH_EXTRUSION_CLASS: 511,
  DWG_TYPE_ACSH_FILLET_CLASS: 512,
  DWG_TYPE_ACSH_HISTORY_CLASS: 513,
  DWG_TYPE_ACSH_LOFT_CLASS: 514,
  DWG_TYPE_ACSH_PYRAMID_CLASS: 515,
  DWG_TYPE_ACSH_REVOLVE_CLASS: 516,
  DWG_TYPE_ACSH_SPHERE_CLASS: 517,
  DWG_TYPE_ACSH_SWEEP_CLASS: 518,
  DWG_TYPE_ACSH_TORUS_CLASS: 519,
  DWG_TYPE_ACSH_WEDGE_CLASS: 520,
  DWG_TYPE_ALDIMOBJECTCONTEXTDATA: 521,
  DWG_TYPE_ALIGNMENTPARAMETERENTITY: 522,
  DWG_TYPE_ANGDIMOBJECTCONTEXTDATA: 523,
  DWG_TYPE_ANNOTSCALEOBJECTCONTEXTDATA: 524,
  DWG_TYPE_ARCALIGNEDTEXT: 525,
  DWG_TYPE_ARC_DIMENSION: 526,
  DWG_TYPE_ASSOC2DCONSTRAINTGROUP: 527,
  DWG_TYPE_ASSOC3POINTANGULARDIMACTIONBODY: 528,
  DWG_TYPE_ASSOCACTION: 529,
  DWG_TYPE_ASSOCACTIONPARAM: 530,
  DWG_TYPE_ASSOCALIGNEDDIMACTIONBODY: 531,
  DWG_TYPE_ASSOCARRAYACTIONBODY: 532,
  DWG_TYPE_ASSOCARRAYMODIFYACTIONBODY: 533,
  DWG_TYPE_ASSOCARRAYMODIFYPARAMETERS: 534,
  DWG_TYPE_ASSOCARRAYPATHPARAMETERS: 535,
  DWG_TYPE_ASSOCARRAYPOLARPARAMETERS: 536,
  DWG_TYPE_ASSOCARRAYRECTANGULARPARAMETERS: 537,
  DWG_TYPE_ASSOCASMBODYACTIONPARAM: 538,
  DWG_TYPE_ASSOCBLENDSURFACEACTIONBODY: 539,
  DWG_TYPE_ASSOCCOMPOUNDACTIONPARAM: 540,
  DWG_TYPE_ASSOCDEPENDENCY: 541,
  DWG_TYPE_ASSOCDIMDEPENDENCYBODY: 542,
  DWG_TYPE_ASSOCEDGEACTIONPARAM: 543,
  DWG_TYPE_ASSOCEDGECHAMFERACTIONBODY: 544,
  DWG_TYPE_ASSOCEDGEFILLETACTIONBODY: 545,
  DWG_TYPE_ASSOCEXTENDSURFACEACTIONBODY: 546,
  DWG_TYPE_ASSOCEXTRUDEDSURFACEACTIONBODY: 547,
  DWG_TYPE_ASSOCFACEACTIONPARAM: 548,
  DWG_TYPE_ASSOCFILLETSURFACEACTIONBODY: 549,
  DWG_TYPE_ASSOCGEOMDEPENDENCY: 550,
  DWG_TYPE_ASSOCLOFTEDSURFACEACTIONBODY: 551,
  DWG_TYPE_ASSOCMLEADERACTIONBODY: 552,
  DWG_TYPE_ASSOCNETWORK: 553,
  DWG_TYPE_ASSOCNETWORKSURFACEACTIONBODY: 554,
  DWG_TYPE_ASSOCOBJECTACTIONPARAM: 555,
  DWG_TYPE_ASSOCOFFSETSURFACEACTIONBODY: 556,
  DWG_TYPE_ASSOCORDINATEDIMACTIONBODY: 557,
  DWG_TYPE_ASSOCOSNAPPOINTREFACTIONPARAM: 558,
  DWG_TYPE_ASSOCPATCHSURFACEACTIONBODY: 559,
  DWG_TYPE_ASSOCPATHACTIONPARAM: 560,
  DWG_TYPE_ASSOCPERSSUBENTMANAGER: 561,
  DWG_TYPE_ASSOCPLANESURFACEACTIONBODY: 562,
  DWG_TYPE_ASSOCPOINTREFACTIONPARAM: 563,
  DWG_TYPE_ASSOCRESTOREENTITYSTATEACTIONBODY: 564,
  DWG_TYPE_ASSOCREVOLVEDSURFACEACTIONBODY: 565,
  DWG_TYPE_ASSOCROTATEDDIMACTIONBODY: 566,
  DWG_TYPE_ASSOCSWEPTSURFACEACTIONBODY: 567,
  DWG_TYPE_ASSOCTRIMSURFACEACTIONBODY: 568,
  DWG_TYPE_ASSOCVALUEDEPENDENCY: 569,
  DWG_TYPE_ASSOCVARIABLE: 570,
  DWG_TYPE_ASSOCVERTEXACTIONPARAM: 571,
  DWG_TYPE_BASEPOINTPARAMETERENTITY: 572,
  DWG_TYPE_BLKREFOBJECTCONTEXTDATA: 573,
  DWG_TYPE_BLOCKALIGNEDCONSTRAINTPARAMETER: 574,
  DWG_TYPE_BLOCKALIGNMENTGRIP: 575,
  DWG_TYPE_BLOCKALIGNMENTPARAMETER: 576,
  DWG_TYPE_BLOCKANGULARCONSTRAINTPARAMETER: 577,
  DWG_TYPE_BLOCKARRAYACTION: 578,
  DWG_TYPE_BLOCKBASEPOINTPARAMETER: 579,
  DWG_TYPE_BLOCKDIAMETRICCONSTRAINTPARAMETER: 580,
  DWG_TYPE_BLOCKFLIPACTION: 581,
  DWG_TYPE_BLOCKFLIPGRIP: 582,
  DWG_TYPE_BLOCKFLIPPARAMETER: 583,
  DWG_TYPE_BLOCKGRIPLOCATIONCOMPONENT: 584,
  DWG_TYPE_BLOCKHORIZONTALCONSTRAINTPARAMETER: 585,
  DWG_TYPE_BLOCKLINEARCONSTRAINTPARAMETER: 586,
  DWG_TYPE_BLOCKLINEARGRIP: 587,
  DWG_TYPE_BLOCKLINEARPARAMETER: 588,
  DWG_TYPE_BLOCKLOOKUPACTION: 589,
  DWG_TYPE_BLOCKLOOKUPGRIP: 590,
  DWG_TYPE_BLOCKLOOKUPPARAMETER: 591,
  DWG_TYPE_BLOCKMOVEACTION: 592,
  DWG_TYPE_BLOCKPARAMDEPENDENCYBODY: 593,
  DWG_TYPE_BLOCKPOINTPARAMETER: 594,
  DWG_TYPE_BLOCKPOLARGRIP: 595,
  DWG_TYPE_BLOCKPOLARPARAMETER: 596,
  DWG_TYPE_BLOCKPOLARSTRETCHACTION: 597,
  DWG_TYPE_BLOCKPROPERTIESTABLE: 598,
  DWG_TYPE_BLOCKPROPERTIESTABLEGRIP: 599,
  DWG_TYPE_BLOCKRADIALCONSTRAINTPARAMETER: 600,
  DWG_TYPE_BLOCKREPRESENTATION: 601,
  DWG_TYPE_BLOCKROTATEACTION: 602,
  DWG_TYPE_BLOCKROTATIONGRIP: 603,
  DWG_TYPE_BLOCKROTATIONPARAMETER: 604,
  DWG_TYPE_BLOCKSCALEACTION: 605,
  DWG_TYPE_BLOCKSTRETCHACTION: 606,
  DWG_TYPE_BLOCKUSERPARAMETER: 607,
  DWG_TYPE_BLOCKVERTICALCONSTRAINTPARAMETER: 608,
  DWG_TYPE_BLOCKVISIBILITYGRIP: 609,
  DWG_TYPE_BLOCKVISIBILITYPARAMETER: 610,
  DWG_TYPE_BLOCKXYGRIP: 611,
  DWG_TYPE_BLOCKXYPARAMETER: 612,
  DWG_TYPE_CAMERA: 613,
  DWG_TYPE_CELLSTYLEMAP: 614,
  DWG_TYPE_CONTEXTDATAMANAGER: 615,
  DWG_TYPE_CSACDOCUMENTOPTIONS: 616,
  DWG_TYPE_CURVEPATH: 617,
  DWG_TYPE_DATALINK: 618,
  DWG_TYPE_DATATABLE: 619,
  DWG_TYPE_DBCOLOR: 620,
  DWG_TYPE_DETAILVIEWSTYLE: 621,
  DWG_TYPE_DGNDEFINITION: 622,
  DWG_TYPE_DGNUNDERLAY: 623,
  DWG_TYPE_DICTIONARYVAR: 624,
  DWG_TYPE_DICTIONARYWDFLT: 625,
  DWG_TYPE_DIMASSOC: 626,
  DWG_TYPE_DMDIMOBJECTCONTEXTDATA: 627,
  DWG_TYPE_DWFDEFINITION: 628,
  DWG_TYPE_DWFUNDERLAY: 629,
  DWG_TYPE_DYNAMICBLOCKPROXYNODE: 630,
  DWG_TYPE_DYNAMICBLOCKPURGEPREVENTER: 631,
  DWG_TYPE_EVALUATION_GRAPH: 632,
  DWG_TYPE_EXTRUDEDSURFACE: 633,
  DWG_TYPE_FCFOBJECTCONTEXTDATA: 634,
  DWG_TYPE_FIELD: 635,
  DWG_TYPE_FIELDLIST: 636,
  DWG_TYPE_FLIPPARAMETERENTITY: 637,
  DWG_TYPE_GEODATA: 638,
  DWG_TYPE_GEOMAPIMAGE: 639,
  DWG_TYPE_GEOPOSITIONMARKER: 640,
  DWG_TYPE_GRADIENT_BACKGROUND: 641,
  DWG_TYPE_GROUND_PLANE_BACKGROUND: 642,
  DWG_TYPE_HELIX: 643,
  DWG_TYPE_IBL_BACKGROUND: 644,
  DWG_TYPE_IDBUFFER: 646,
  DWG_TYPE_IMAGE: 647,
  DWG_TYPE_IMAGEDEF: 648,
  DWG_TYPE_IMAGEDEF_REACTOR: 649,
  DWG_TYPE_IMAGE_BACKGROUND: 650,
  DWG_TYPE_INDEX: 651,
  DWG_TYPE_LARGE_RADIAL_DIMENSION: 652,
  DWG_TYPE_LAYERFILTER: 653,
  DWG_TYPE_LAYER_INDEX: 654,
  DWG_TYPE_LAYOUTPRINTCONFIG: 655,
  DWG_TYPE_LEADEROBJECTCONTEXTDATA: 656,
  DWG_TYPE_LIGHT: 657,
  DWG_TYPE_LIGHTLIST: 658,
  DWG_TYPE_LINEARPARAMETERENTITY: 659,
  DWG_TYPE_LOFTEDSURFACE: 660,
  DWG_TYPE_MATERIAL: 661,
  DWG_TYPE_MENTALRAYRENDERSETTINGS: 662,
  DWG_TYPE_MESH: 663,
  DWG_TYPE_MLEADEROBJECTCONTEXTDATA: 664,
  DWG_TYPE_MLEADERSTYLE: 665,
  DWG_TYPE_MOVEACTIONENTITY: 666,
  DWG_TYPE_MOTIONPATH: 667,
  DWG_TYPE_MPOLYGON: 668,
  DWG_TYPE_MTEXTATTRIBUTEOBJECTCONTEXTDATA: 669,
  DWG_TYPE_MTEXTOBJECTCONTEXTDATA: 670,
  DWG_TYPE_MULTILEADER: 671,
  DWG_TYPE_NAVISWORKSMODEL: 672,
  DWG_TYPE_NAVISWORKSMODELDEF: 673,
  DWG_TYPE_NPOCOLLECTION: 674,
  DWG_TYPE_NURBSURFACE: 675,
  DWG_TYPE_OBJECT_PTR: 676,
  DWG_TYPE_ORDDIMOBJECTCONTEXTDATA: 677,
  DWG_TYPE_PARTIAL_VIEWING_INDEX: 678,
  //DWG_TYPE_PARTIAL_VIEWING_FILTER,
  DWG_TYPE_PDFDEFINITION: 679,
  DWG_TYPE_PDFUNDERLAY: 680,
  DWG_TYPE_PERSUBENTMGR: 681,
  DWG_TYPE_PLANESURFACE: 682,
  DWG_TYPE_PLOTSETTINGS: 683,
  DWG_TYPE_POINTCLOUD: 684,
  DWG_TYPE_POINTCLOUDCOLORMAP: 685,
  DWG_TYPE_POINTCLOUDDEF: 686,
  DWG_TYPE_POINTCLOUDDEFEX: 687,
  DWG_TYPE_POINTCLOUDDEF_REACTOR: 688,
  DWG_TYPE_POINTCLOUDDEF_REACTOR_EX: 689,
  DWG_TYPE_POINTCLOUDEX: 690,
  DWG_TYPE_POINTPARAMETERENTITY: 691,
  DWG_TYPE_POINTPATH: 692,
  DWG_TYPE_POLARGRIPENTITY: 693,
  DWG_TYPE_RADIMLGOBJECTCONTEXTDATA: 694,
  DWG_TYPE_RADIMOBJECTCONTEXTDATA: 695,
  DWG_TYPE_RAPIDRTRENDERSETTINGS: 696,
  DWG_TYPE_RASTERVARIABLES: 697,
  DWG_TYPE_RENDERENTRY: 698,
  DWG_TYPE_RENDERENVIRONMENT: 699,
  DWG_TYPE_RENDERGLOBAL: 700,
  DWG_TYPE_RENDERSETTINGS:701,
  DWG_TYPE_REVOLVEDSURFACE: 702,
  DWG_TYPE_ROTATIONPARAMETERENTITY: 703,
  DWG_TYPE_ROTATEACTIONENTITY: 704,
  DWG_TYPE_RTEXT: 705,
  DWG_TYPE_SCALE: 706,
  DWG_TYPE_SCALEACTIONENTITY: 707,
  DWG_TYPE_SECTIONOBJECT: 708,
  DWG_TYPE_SECTIONVIEWSTYLE: 709,
  DWG_TYPE_SECTION_MANAGER: 710,
  DWG_TYPE_SECTION_SETTINGS: 711,
  DWG_TYPE_SKYLIGHT_BACKGROUND: 712,
  DWG_TYPE_SOLID_BACKGROUND: 713,
  DWG_TYPE_SORTENTSTABLE: 714,
  DWG_TYPE_SPATIAL_FILTER: 715,
  DWG_TYPE_SPATIAL_INDEX: 716,
  DWG_TYPE_STRETCHACTIONENTITY: 717,
  DWG_TYPE_SUN: 718,
  DWG_TYPE_SUNSTUDY: 719,
  DWG_TYPE_SWEPTSURFACE: 720,
  DWG_TYPE_TABLE: 721,
  DWG_TYPE_TABLECONTENT: 722,
  DWG_TYPE_TABLEGEOMETRY: 723,
  DWG_TYPE_TABLESTYLE: 724,
  DWG_TYPE_TEXTOBJECTCONTEXTDATA: 725,
  DWG_TYPE_TVDEVICEPROPERTIES: 726,
  DWG_TYPE_VISIBILITYGRIPENTITY: 727,
  DWG_TYPE_VISIBILITYPARAMETERENTITY: 728,
  DWG_TYPE_VISUALSTYLE: 729,
  DWG_TYPE_WIPEOUT: 730,
  DWG_TYPE_WIPEOUTVARIABLES: 731,
  DWG_TYPE_XREFPANELOBJECT: 732,
  DWG_TYPE_XYPARAMETERENTITY: 733,
  DWG_TYPE_BREAKDATA: 734,
  DWG_TYPE_BREAKPOINTREF: 735,
  DWG_TYPE_FLIPGRIPENTITY: 736,
  DWG_TYPE_LINEARGRIPENTITY: 737,
  DWG_TYPE_ROTATIONGRIPENTITY: 738,
  DWG_TYPE_XYGRIPENTITY: 739,

  /* preR13 entities */
  DWG_TYPE__3DLINE: 740,
  DWG_TYPE_REPEAT: 741,
  DWG_TYPE_ENDREP: 742,
  DWG_TYPE_JUMP: 743,
  /* pre2.0 entities */
  DWG_TYPE_LOAD: 744,
  // after 1.0 add new types here for binary compat

  DWG_TYPE_FREED: 0xfffd,
  DWG_TYPE_UNKNOWN_ENT: 0xfffe,
  DWG_TYPE_UNKNOWN_OBJ: 0xffff
})

export const Dwg_Object_Type_Inverted = Object.fromEntries(
  Object.entries(Dwg_Object_Type).map(([key, value]) => [value, key])
)

export const dwg_read_data = (fileContent) => {
  const fileName = 'tmp.dwg'
  libredwg.FS.writeFile(
    fileName,
    new Uint8Array(fileContent)
  )
  const result = libredwg.dwg_read_file(fileName)
  if (result.error != 0) {
    console.log('Open dwg file with error code: ', result.error)
  }
  libredwg.FS.unlink(fileName)
  return result.data
}

export const dwg_getall_object_by_type = (data, type) => {
  const num_objects = libredwg.dwg_get_num_objects(data)
  const results = []
  for (let i = 0; i < num_objects; i++) {
    const obj = libredwg.dwg_get_object(data, i)
    const tio = libredwg.dwg_object_to_object_tio(obj)
    if (tio && libredwg.dwg_object_get_fixedtype(obj) == type) {
      results.push(tio)
    }
  }
  return results
}

export const dwg_getall_entity_by_type = (data, type) => {
  const num_objects = libredwg.dwg_get_num_objects(data)
  const results = []
  for (let i = 0; i < num_objects; i++) {
    const obj = libredwg.dwg_get_object(data, i)
    const tio = libredwg.dwg_object_to_entity_tio(obj)
    if (tio && libredwg.dwg_object_get_fixedtype(obj) == type) {
      results.push(tio)
    }
  }
  return results
}

export const dwg_getall_entities_in_model_space = (data) => {
  const model_space = libredwg.dwg_model_space_object(data)
  const entities = []
  let next = libredwg.get_first_owned_entity(model_space)
  while (next) {
    entities.push(next)
    next = libredwg.get_next_owned_entity(model_space, next)
  }
  return entities
}

export const dwg_getall_LAYER = (data) => {
  return dwg_getall_object_by_type(data, Dwg_Object_Type.DWG_TYPE_LAYER)
}

export const dwg_getall_LTYPE = (data) => {
  return dwg_getall_object_by_type(data, Dwg_Object_Type.DWG_TYPE_LTYPE)
}

export const dwg_getall_STYLE = (data) => {
  return dwg_getall_object_by_type(data, Dwg_Object_Type.DWG_TYPE_STYLE)
}

export const dwg_getall_DIMSTYLE = (data) => {
  return dwg_getall_object_by_type(
    data,
    Dwg_Object_Type.DWG_TYPE_DIMSTYLE
  )
}

export const dwg_getall_VPORT = (data) => {
  return dwg_getall_object_by_type(data, Dwg_Object_Type.DWG_TYPE_VPORT)
}

export const dwg_getall_LAYOUT = (data) => {
  return dwg_getall_object_by_type(data, Dwg_Object_Type.DWG_TYPE_LAYOUT)
}

export const dwg_getall_BLOCK = (data) => {
  return dwg_getall_object_by_type(data, Dwg_Object_Type.DWG_TYPE_BLOCK)
}

export const dwg_getall_BLOCK_HEADER = (data) => {
  return dwg_getall_object_by_type(
    data,
    Dwg_Object_Type.DWG_TYPE_BLOCK_HEADER
  )
}

export const dwg_getall_IMAGEDEF = (data) => {
  return dwg_getall_object_by_type(
    data,
    Dwg_Object_Type.DWG_TYPE_IMAGEDEF
  )
}

export const dwg_getall_VERTEX_2D = (data) => {
  return dwg_getall_entity_by_type(
    data,
    Dwg_Object_Type.DWG_TYPE_VERTEX_2D
  )
}

export const dwg_getall_VERTEX_3D = (data) => {
  return dwg_getall_entity_by_type(
    data,
    Dwg_Object_Type.DWG_TYPE_VERTEX_3D
  )
}

export const dwg_getall_POLYLINE_2D = (data) => {
  return dwg_getall_entity_by_type(
    data,
    Dwg_Object_Type.DWG_TYPE_POLYLINE_2D
  )
}

export const dwg_getall_POLYLINE_3D = (data) => {
  return dwg_getall_entity_by_type(
    data,
    Dwg_Object_Type.DWG_TYPE_POLYLINE_3D
  )
}

export const dwg_getall_IMAGE = (data) => {
  return dwg_getall_entity_by_type(data, Dwg_Object_Type.DWG_TYPE_IMAGE)
}

export const dwg_getall_LWPOLYLINE = (data) => {
  return dwg_getall_entity_by_type(
    data,
    Dwg_Object_Type.DWG_TYPE_LWPOLYLINE
  )
}